<nav>
  <ul class="tabs" data-hook="admin_order_tabs">
    <% if (@order.shipments.count == 0 || @order.shipped_shipments.count == 0) %>
      <li class="<%= "active" if current == "Cart" %>" data-hook='admin_order_tabs_order_details'>
        <%= link_to Spree.t(:cart), spree.cart_admin_order_url(@order) %>
      </li>
    <% end %>

    <% if checkout_steps.include?("address") %>
      <li class="<%= "active" if (current == "Customer Details") %>" data-hook='admin_order_tabs_customer_details'>
        <% if can?(:update, @order) %>
          <%= link_to Spree.t(:customer), spree.edit_admin_order_customer_url(@order) %>
        <% else %>
          <%= link_to Spree.t(:customer), spree.admin_order_customer_url(@order) %>
        <% end %>
      </li>
    <% end %>

    <li class="<%= "active" if current == "Shipments" %>" data-hook='admin_order_tabs_order_details'>
      <%= link_to plural_resource_name(Spree::Shipment), spree.edit_admin_order_url(@order) %>
    </li>

    <% if can? :display, Spree::Adjustment %>
      <li class="<%= "active" if current == "Adjustments" %>" data-hook='admin_order_tabs_adjustments'>
        <%= link_to plural_resource_name(Spree::Adjustment), spree.admin_order_adjustments_url(@order) %>
      </li>
    <% end %>

    <% if can?(:display, Spree::Payment) %>
      <li class="<%= "active" if current == "Payments" %>" data-hook='admin_order_tabs_payments'>
        <%= link_to plural_resource_name(Spree::Payment), spree.admin_order_payments_url(@order) %>
      </li>
    <% end %>

    <% if !@order.completed? && can?(:update, @order) %>
      <li class="<%= "active" if current == "Confirm" %>" data-hook='admin_order_tabs_confirm'>
        <%= link_to Spree.t(:confirm), spree.confirm_admin_order_url(@order) %>
      </li>
    <% end %>

    <% if can? :display, Spree::ReturnAuthorization %>
      <% if @order.completed? %>
        <li class="tab <%= "active" if current == "Return Authorizations" %>" data-hook='admin_order_tabs_return_authorizations'>
          <%= link_to Spree.t('admin.tab.rma'), spree.admin_order_return_authorizations_url(@order) %>
        </li>
      <% end %>
    <% end %>

    <% if can? :display, Spree::CustomerReturn %>
      <% if @order.completed? %>
        <li class="<%= "active" if current == "Customer Returns" %>">
          <%= link_to plural_resource_name(Spree::CustomerReturn), spree.admin_order_customer_returns_url(@order) %>
        </li>
      <% end %>
    <% end %>

    <% if can?(:manage, Spree::OrderCancellations) && @order.inventory_units.cancelable.present? %>
      <%= content_tag('li', class: "#{'active' if current == 'Cancel Inventory'}", :data => {:hook => 'admin_order_tabs_cancel_inventory'}) do %>
        <%= link_to Spree.t(:cancel_inventory), spree.admin_order_cancellations_path(@order) %>
      <% end %>
    <% end %>
  </ul>
</nav>
